package t20240516_lineage;

import java.util.regex.Pattern;

public class TestUtil {

    public static final String SQL_EMPTY_STR = "[\\s\\t\\n\\r]";

    public static void main(String[] args) {
        String sql = "create VIEW o_scdn_vod_xserver_ngx_httpcode_fliter as             \n" +
                "select\n" +
                "    *\n" +
                "from o_scdn_vod_xserver_ngx_httpcode\n" +
                "where\n" +
                "    (\n" +
                "    (level = 'edge' and `port` in (80, 443, 9102, 9305))\n" +
                "    or (level = 'area' and `port` in (80, 9102))\n" +
                "    or (level = 'root' and `port` = 80)\n" +
                "    )\n" +
                "    and `domain` <> '\\N'\n" +
                "    and `hostname` <> '\\N'\n" +
                "    and level <> '\\N'";




        String reg = "^CREATE\\s+VIEW.*AS\\s+SELECT.*$";
        Pattern compile = Pattern.compile(reg, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);

        sql = sql.replaceAll(SQL_EMPTY_STR, " ").trim().toUpperCase();

        System.out.println(sql);
        boolean matches = compile.matcher(sql).matches();
        System.out.println(matches);

    }
}
